Loading...
 

Email and fax solutions

Programming of mail and fax solutions

ClassiX® does not support mail or fax protocols by itself. To be able to send an e-mail or a fax from ClassiX® anyway, external applications have to be integrated. This is done via OLE automation, i.e. the application to be integrated must be controllable via OLE automation. In the following, Outlook is used as an e-mail and fax client. However, Lotus Notes and similar applications can also be integrated in a similar way.

Outlook offers a comprehensive object model for programming (similar to MAPI - Mail Application Programming Interface), which is independent of whether Outlook works as a stand-alone mail programme or is connected to an Exchange server. For more detailed information, see e.g. 1 or 2.

Sending an EMail

To send an email programmatically from Outlook the following steps are necessary:

  1. Getting the Outlook Application Object
  2. Log in
  3. Create mail
  4. Set addressee(s)
  5. Set subject, body and attachment if necessary
  6. View (preview)
  7. send
  8. Log off

1. get the Outlook application object
The application object provides methods to control the application, in this case methods to navigate through the Outlook folders, to create new mails or contacts or to change the Outlook interface.

    Var(olApp)
    CreateTransObject(CX_COM_OBJECT) -> olApp 
    "Outlook.Application" olApp Call(CreateFromProgID) 

An object of the type Outlook.Application was created with this. The method CreateFromProgID cannot be found in the Outlook help because it is a method of the ClassiX® class CX_COM_OBJECT.

2. log in
MAPI requires that a user - even a programme that wants to do something is a user - first logs in and thus opens a session. This is done via the MAPI namespace:

    Var(olSession)
    "MAPI" olApp Call(GetNamespace) -> olSession
    olSession Call(Logon)

The logon command also accepts parameters for (interactive) profile selection and a password. In the version shown above, the default profile is used.

3. create mail
Each element, whether mail, contact or note, is created with the method CreateItem of the Application object. The type is passed as a parameter in the form of an integer. A mail is created by the type olMailItem (0):

    Var(olMail) 0 olApp Call(CreateItem) -> olMail

The object created is of the type Outlook.MailItem

4. set addressee(s)
Addressees are first set in string form, i.e. the email address or the name of the recipient is set. Then it can be checked whether the recipient or all recipients are valid recipients from Outlook's point of view. This is always the case with SMPT addresses (xyz@abc.de), unless the Internet mail service has not been installed. If a name is specified, Outlook checks whether a corresponding contact or entry exists in the address book and whether a valid mail address is assigned in each case.

    Var(olRecipients) olMail Call(GetRecipients) -> olRecipients
    "info@classix.de" olRecipients Call(Add) Drop
    "Egon Hubert" olRecipients Call(Add) Drop
    olRecipients Call(ResolveAll) ifnot {... Error handling ...}

Set subject, body and, if necessary, attachment.
The subject and body of a mail are set as simple strings and can also be read as such. If the mail is to be sent in HTML format, HTMLBody can be used instead of Body.

    "irgendein Betreff" olMail Call(PutSubject)
    "irgendein Inhalt" olMail Call(PutBody)

Attachments are attached as file names:

    "c:\\irgendwo\\irgendwas.doc" olMail Call(GetAttachments) Call(Add)

6. view (preview)
To bring the connected application (Outlook, Notes, etc.) to the foreground, the following method can be called:

    olMail Call(Display)

7. send
To send, simply call the method Send from the MailItem:

    olMail Call(Send)

There is no confirmation for sending a mail. If you want to have something like that, you would have to write a plugin in Outlook or for Exchange, which generates a message for ClassiX® when sending.

8. sign out
The namespace provides a method to log out. While nothing happens if you don't log out, it is recommended for clean development:

    olSession Call(Logoff)

Sending a fax

In order to send faxes with the help of ClassiX®, an OLE automation capable fax application must also be available. In addition to the simple printer drivers, which allow a modem, an ISDN card or a central fax server to be controlled instead of a printer, Exchange and Outlook offer very elegant solutions for sending faxes.

Basically, Outlook and Exchange support various transmission and addressing protocols. In addition to SMPT/, which is common on the Internet, X.400/X.500 protocols, among others, are also supported. For this, only the correct service provider must be installed (in an Exchange installation only on the Exchange server, otherwise in every Outlook installation).

The service provider tries to find the appropriate recipient (contact or entry in the address book) based on the transferred address and transmits the message to one of the addresses stored in the recipient via installed transmission protocols. In doing so, the address and the matching protocol that was specified as the receiving address are preferred. If the recipient is not stored, the transferred address is checked for possible protocols (e.g. if it contains an @, it is probably SMTP). If you want to use a specific protocol, this can be specified in the form:

[Protokoll:Adresse]

as the recipient address. e.g.:

[smpt:max.mustermann@classix.de]

This tells Exchange/Outlook that the address belongs to a certain protocol and that the message should be sent via it.

To be able to fax, a fax provider must be set up on the Exchange server or under Outlook (e.g.. GFI FaxMaker). The protocol name depends on the product, but is often "fax" or according to the manufacturer, e.g. "faxmaker", so that a complete fax address can look like this, for example:

„[fax:04020940150]“

To send a fax, simply send an email to such an address (send an email from ClassiX® ). The sending programme converts the content into the required graphic format (faxes are transmitted as graphics), whereby attachments are also taken into account. However, attachments must be in a printable format, i.e. the converter must be able to open and print the attachment. If, for example, an Acrobat PDF file is sent as an attachment and the fax provider runs on an Exchange server, an Acrobat reader must be installed on this server. The registry then contains information on how this PDF file can be printed. Depending on the fax provider, these entries must be adapted.